<?php
declare(strict_types=1);

namespace App\Common\Modular\System\Traits\Configure\Traits;

use Core\Package\ElementPlus\Component\Component;
use Core\Package\ElementPlus\FormCreate\FormItem;

trait ViolateForm
{
    public function getViolateFormRule($configure): array
    {
        return [
            FormItem::Switchs('open', '违禁词检测', (string)($configure['open'] ?? '1'))->activeText('开启检测')->inactiveText('关闭检测'),
            FormItem::Radio('model', '检测模式', $configure['model'] ?? 'warn')
                ->options([['value' => 'warn', 'label' => '警告'], ['value' => 'replace', 'label' => '替换']])
                ->control([
                    [
                        'value' => 'warn',
                        'rule' => [
                            Component::Alert('警告模式:用户提交包含违禁词的内容系统会发出警告', 'success')->style(['margin' => '0 0 20px 150px']),
                        ]
                    ],
                    [
                        'value' => 'replace',
                        'rule' => [
                            Component::Alert('替换模式,用户提交包含违禁词的内容系统会替换为*号', 'warning')->style(['margin' => '0 0 20px 150px']),
                        ]
                    ],
                ])
                ->required('请选怎验证模式'),
            FormItem::Labels('words', '词汇管理', $configure['words'] ?? [])->maxlength(50)->limit(2000)->required('请设置违禁词汇')
        ];
    }
}